/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package admin.beans;

import abstractClasses.AbstractFilterableEntityList;
import entities.Candidate;
import facades.CandidateFacade;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Event;
import javax.faces.model.SelectItem;
import javax.inject.Inject;
import javax.inject.Named;
import qualifiers.EditedEntityEvent;
import qualifiers.PreEditEntityEvent;
import qualifiers.PreRemoveEntityEvent;
import qualifiers.RemovedEntityEvent;

/**
 *
 * @author Alvaro
 */
@Named(value = "adminCandidateBean")
@SessionScoped
public class AdminCandidateBean extends AbstractFilterableEntityList<Candidate, CandidateFacade> implements Serializable {
    @Inject
    @PreRemoveEntityEvent
    private Event<Candidate> preRemoveCandidateEvent;
    @Inject
    @RemovedEntityEvent
    private Event<Candidate> removeCandidateEvent;
    @Inject
    @PreEditEntityEvent
    private Event<Candidate> preEditCandidateEvent;
    @Inject
    @EditedEntityEvent
    private Event<Candidate> editedCandidateEvent;
    @Inject
    private CandidateFacade candidateFacade;
    /**
     * Creates a new instance of AdminCompanyBean
     */
    public AdminCandidateBean() {
    }

//    @Override
//    @PostConstruct
//    public void init(){
//        setEntityFacade(getEntityFacadeInstance().get());
//        setEntityList(new ArrayList<Candidate>());
//    }
    
    @Override
    public String redirectToViewEntity() {
        return null;
    }
    
    
//    public Boolean isValidCandidate(Candidate candidate){        
//        Boolean res = false;
//        if(candidate!=null){
//             res=candidateFacade.isValidCandidate(candidate);
//        }
//        return res;        
//    }
    
    public SelectItem[] getTrueFalseOptions() {
        SelectItem[] options = new SelectItem[3];  
        options[0] = new SelectItem("", "Indiferente");
        options[1] = new SelectItem(Boolean.TRUE.toString(), "Sí");
        options[2] = new SelectItem(Boolean.FALSE.toString(), "No");
        return options;  
    }
    
    public void removeProfile(){
        preRemoveCandidateEvent.fire(getChosenEntity());
        candidateFacade.remove(getChosenEntity());
        removeCandidateEvent.fire(getChosenEntity());
    }
    
    public void editProfile(){
        preEditCandidateEvent.fire(getChosenEntity());
        candidateFacade.edit(getChosenEntity());
        editedCandidateEvent.fire(getChosenEntity());
    }
}
